//
//  MSQTextField.m
//  AiShangJinFuSalesman
//
//  Created by AiShangTong on 2017/6/26.
//  Copyright © 2018年 AiShangTong. All rights reserved.
//

#import "MSQTextField.h"

@implementation MSQTextField

- (instancetype)init {
    
    self = [super init];
    if (self) {
        [self setValue:HexColor(0xaaaaaa) forKeyPath:@"_placeholderLabel.color"];
        self.textColor = HexColor(0x333333);
    }
    return self;
}
/**
 *  设置Placeholder
 */
- (void)customWithPlaceholder: (NSString *)placeholder color: (UIColor *)color font: (UIFont *)font {
    
    self.placeholder = placeholder;
    [self setValue:HexColor(0xaaaaaa) forKeyPath:@"_placeholderLabel.color"];
}


/**
 *  控制编辑文本的位置
 */
-(CGRect)editingRectForBounds:(CGRect)bounds

{
    
    CGRect inset = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
    
    return inset;
    
}

/**
 *  控制显示文本的位置
 */
-(CGRect)textRectForBounds:(CGRect)bounds

{
    self.autocapitalizationType = UITextAutocapitalizationTypeNone;
    CGRect inset = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
    
    return inset;
    
    
}


/**
 清除按钮位置
 */
-(CGRect)clearButtonRectForBounds:(CGRect)bounds {
    
    CGRect inset = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
    CGRect clearButtonRect = [super clearButtonRectForBounds:inset];
    return clearButtonRect;
}

- (CGRect)placeholderRectForBounds:(CGRect)bounds{
    CGRect inset = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
    
    return inset;
}

@end
